<template>
  <div class="navigation">
    <a-layout id="components-layout-demo-top" class="layout">
      <a-layout-header>
        <a-row class="a-row">
          <a-col class="a-col" :md="6" :span="11" v-if="flag">
            <img :src="Logo" class="logo" @click="home" />
          </a-col>
          <a-col class="a-col" style="text-align: left" :md="15" :span="10">
              
            <div class="wai">
                    
              <div
                class="parent"
                :style="{ color: count == index ? CoLor : '#FFF' }"
                @mouseenter="info(index)"
                @mouseleave="hid(index)"
                v-for="(item, index) in navigation"
                :key="index"
              >
                 <span class="shang" :class="{ activeb: count === index }">{{
                  item.title
                }}</span
                >       
                <div
                  v-if="item.children"
                  class="children"
                  :style="{ display: count == index ? hide : 'none' }"
                >
                  <div
                    class="child"
                    v-for="(item, index) in item.children"
                    :key="index"
                    @click="seleter(item.path)"
                  >
                      {{ item.title }}
                  </div>
                            
                </div>
                              
              </div>
                  
            </div>
          </a-col>
          <a-col class="a-col" :md="2" :span="3">
            <span style="color: #fff">登录</span>
            <img :src="login" alt="" />
          </a-col>
        </a-row>
      </a-layout-header>
    </a-layout>
  </div>
</template>
<script>
module.exports = {
  data() {
    return {
      count: 0,
      hide: "none",
      CoLor: "#fff",
      navigations: [
        {
          title: "首页",
        },
        {
          title: "管理",
        },
        {
          title: "个人中心",
        },
      ],
    };
  },
  props: {
    //logo 状态
    flag: {
      type: Boolean,
      default: true,
    },
    navigation: {
      type: Array,
      default: () => [],
    },

    Logo: {
      type: String,
      default: "http://localhost:8080/ui/demo/assets/images/logo.png",
    },
    login: {
      type: String,
      default: "http://localhost:8080/ui/demo/assets/images/avatar.png",
    },
  },

  methods: {
    info(index) {
      this.count = index;
      this.hide = "block";
      this.CoLor = "#f8b551";
    },
    hid() {
      this.hide = "none";
      this.CoLor = "#fff";
    },
    //首页路由
    home() {
      this.$router.push({ path: "/home" });
    },
    seleter(path) {
      this.$router.push({ path });
    },
  },
};
</script>
<style scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.logo {
  display: inline-block;
  width: 183px;
  height: 43.5px;
  line-height: 50px;
}
.order {
  margin-top: 10px;
  text-align: left;
  width: 80%;
  margin-left: 200px;
  height: 25px;
  box-sizing: border-box;
  line-height: 25px;
}
.wai {
  display: flex;
  justify-content: flex-start;
  position: absolute;
  left: 0;
  top: 0;
}
.child {
  color: #fff;
}
.child:hover {
  color: sandybrown;
}
.parent {
  color: #fff;
  font-size: 18px;
  display: block;
  margin: 15px -5px 10px -5px;
  width: 150px;
  line-height: 30px;
  cursor: pointer;
  text-align: center;
}

.parent:hover {
  color: sandybrown;
}
.children {
  background: #333333;
  text-align: center;
  width: 100%;
  position: relative;
  z-index: 9999;
  cursor: pointer;
}
.shang {
  width: 100px;
  margin-bottom: -10px;
  text-align: center;
  display: inline-block;
}
.activeb {
  border-bottom: 2px solid sandybrown;
}

.fade-enter {
  opacity: 0;
}
.fade-leave {
  opacity: 1;
}
.fade-enter-active {
  transition: opacity 0.5s;
}
.fade-leave-active {
  opacity: 0;
  transition: opacity 0.5s;
}
.a-row {
  height: 100%;
  box-sizing: border-box;
}
.a-col {
  box-sizing: border-box;
  height: 100%;
  position: relative;
}

.active {
  font-family: MicrosoftYaHei;
  font-size: 18px;
  font-weight: bold;
  font-stretch: normal;
  border-bottom: 2px solid #f8b551;
  color: #f8b551;
  cursor: pointer;
  padding: 10px 0;
  text-align: center;
}
.active2 {
  font-family: MicrosoftYaHei;
  font-size: 18px;
  font-weight: bold;
  font-stretch: normal;
  color: #f8b551;
  cursor: pointer;
}
.active {
  display: none;
}
.tags:last-child {
  margin-right: 0;
}
.leftColor {
  color: #3ba0e9;
  border-bottom: 1px solid #ccc;
  cursor: pointer;
}

#components-layout-demo-basic {
  text-align: center;
}
#components-layout-demo-basic .ant-layout-header {
  background: #333333;
  color: #fff;
  text-align: center;
}
</style> 